jQuery(document).ready(function() {
	$('#kit-search-more').on('click', function() {
		$('.kit-search-mored').toggle();
	});
	
	var col = [ 
	{
	checkbox: 'checkbox'
	},
	{
		title:'id',
		field:'id',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'购买课程ID',
		field:'purchaseCourseId',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'上课日期',
		field:'classDate',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'周几',
		field:'classWeek',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'上课时间（开始）',
		field:'classTime',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'上课结束时间',
		field:'classTimeEnd',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'课程时长（单位分钟）',
		field:'classLength',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'教材',
		field:'material',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'状态',
		field:'state',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'教师ID',
		field:'teacherId',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'教师评语（上课表现）',
		field:'performance',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'作业',
		field:'homework',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'预习',
		field:'contentNextLecture',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'上课视频',
		field:'zoomVideo',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'is_delete',
		field:'isDelete',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'学生ID',
		field:'studentId',
		align: 'center',
		valign: 'middle'
	}];

	//------------------------------------------加载列表
	$('#_table').bootstrapTable({
		url:baseUrl+ '/curriculumSchedules',
		'method': "GET",
		locale: 'zh-CN',
		detailView: false,
		sidePagination: "server", //服务端处理分页
		striped: true,//隔行变色
		undefinedText: "",
		pagination: true,
		singleSelect: false,
		pageSize: pageList[0],
		cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
		pageNumber: 1,
		pageList: pageList,
		search: false, //不显示 搜索框
		uniqueId: "id", //每一行的唯一标识，一般为主键列
		showColumns: false, //不显示下拉框（选择显示的列）
		undefinedText: '',
		columns: col,
		queryParams: function(params) {
			return {
				pageNum: this.pageNumber,
				pageSize: this.pageSize,
				sortOrder: params.order
			}
		},
		
	});

})
var check = function() {

}
var doDelete = function() {
	var rows = $('#_table').bootstrapTable('getSelections');
	if(rows == [] || rows == null || rows.length == 0) {
		parent.layer.alert('请选择要编辑的数据！', {
			skin: 'layui-layer-molv', //样式类名
			closeBtn: 0,
			anim: 4,
			time: 2000
		});
		return;
	}
	if(rows.length != 1) {
		parent.layer.alert('请选择单条数据进行编辑！', {
			skin: 'layui-layer-molv', //样式类名
			closeBtn: 0,
			anim: 4,
			time: 1800
		});
		return;
	}
	$.ajax({
		type: "delete",
		url:baseUrl+ '/curriculumSchedules/' + rows[0].id,
		async: true,
		success: function(data) {
			alert(data.msg);
			$('#_table').bootstrapTable('refresh');
		}
	});
}
var insert = function() {
	parent.layer.open({
		//				title: false,
		maxmin: true,
		type: 2,
		area: modalArea,
		content: './views/form/CurriculumScheduleEdit.html',
		btn: ['保存', '取消'],
		yes: function(index, layero) {
			var data = $(layero).find("iframe")[0].contentWindow.callback_save();
			console.log(layero);
			$.ajax({
				url: baseUrl+'/curriculumSchedules',
				type: 'POST',
				data: data,
				success: function(data) {
					alert(data.msg);
					parent.layer.close(index);
					$('#_table').bootstrapTable('refresh');
				}
			});
		},
		btn2: function(index, layero) {
			//按钮【按钮二】的回调
			console.log(layero);
			//return false 开启该代码可禁止点击该按钮关闭
		}
	});
}

var edit = function() {
	var rows = $('#_table').bootstrapTable('getSelections');
	if(rows == [] || rows == null || rows.length == 0) {
		parent.layer.alert('请选择要编辑的数据！', {
			skin: 'layui-layer-molv', //样式类名
			closeBtn: 0,
			anim: 4,
			time: 2000
		});
		return;
	}
	if(rows.length != 1) {
		parent.layer.alert('请选择单条数据进行编辑！', {
			skin: 'layui-layer-molv', //样式类名
			closeBtn: 0,
			anim: 4,
			time: 1800
		});
		return;
	}
	parent.layer.open({
		//				title: false,
		maxmin: true,
		type: 2,
		area: modalArea,
		content: './views/form/CurriculumScheduleEdit.html?id='+rows[0].id, //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
		btn: ['保存', '取消'],
		yes: function(index, layero) {
			var data = $(layero).find("iframe")[0].contentWindow.callback_save();
			console.log(layero);
			$.ajax({
				url:baseUrl+'/curriculumSchedules/'+rows[0].id,
				type: 'POST',
				data: data,
				success: function(data) {
					alert(data.msg);
					parent.layer.close(index);
					$('#_table').bootstrapTable('refresh');
				}
			});
		},
		btn2: function(index, layero) {
			//按钮【按钮二】的回调
			alert(index);
			console.log(layero);
			//return false 开启该代码可禁止点击该按钮关闭
		}
	});
}
